home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.3 (Developer)…68k, x86, SPARC, PA-RISC] / NeXTSTEP 3.3 Dev Intel.iso / NextDeveloper / Headers / bsd / dev / fd_extern.h < prev    next >
Text File  |  1995-02-14  |  19KB  |  708 lines

  1. /*    @(#)fd_extern.h     2.0    01/25/90    (c) 1990 NeXT    
  2.  *
  3.  * fd_vars.h -- Externally used data structures and constants for Floppy 
  4.  *        Disk driver
  5.  *
  6.  * KERNEL VERSION
  7.  *
  8.  * HISTORY
  9.  * 13-May-94    Dean Reece
  10.  *    Added define and struct for FDIOCGCAPLIST to return possible
  11.  *    format densities.  Enables workspace to build a menu.
  12.  * 20-Mar-91    Doug Mitchell
  13.  *    Made #importing  pmap.h and vm_map.h dependent on #ifdef KERNEL.
  14.  * 25-Jan-90    Doug Mitchell at NeXT
  15.  *    Created.
  16.  *
  17.  */
  18.  
  19. #ifndef    _FDEXTERN_
  20. #define _FDEXTERN_
  21.  
  22. #import <sys/types.h>
  23. #import <sys/ioctl.h>
  24. #ifdef    KERNEL
  25. #import <machdep/machine/pmap.h>
  26. #import <vm/vm_map.h>
  27. #endif    KERNEL
  28. #import <mach/boolean.h>
  29. #import <mach/vm_param.h>
  30. #define FD_CMDSIZE    0x10        /* max size of command passed to 
  31.                      * controller */
  32. #define FD_STATSIZE    0x10        /* max size of status array returned
  33.                      * from controller */
  34. #define    FD_MAX_CAP_LIST    8
  35.                      
  36. typedef    int fd_return_t;        /* see FDR_xxx, below */
  37.  
  38. struct fd_drive_stat {
  39.     u_char        media_id:2,    /* media type currently inserted. See
  40.                      * FD_MID_xxx, below. */
  41.              motor_on:1,    /* state of motor at I/O complete 
  42.                      * 1 = on; 0 = off */
  43.             write_prot:1,    /* write protect 1 = Write Protected */
  44.             drive_present:1,
  45.             rsvd1:3;    /* reserved */
  46. };
  47.  
  48. /*
  49.  * Format Capacity List struct.  Returned by FDIOCGCAPLIST ioctl as a list
  50.  * of possible format capacities.  Entries are possible capacities
  51.  * in 1k (1024) units.  List is null terminated, so the useful size is
  52.  * (FD_MAX_CAP_LIST - 1).
  53.  */
  54. struct fd_cap_list {
  55.     int        capacity[FD_MAX_CAP_LIST];
  56. };
  57.  
  58. /*
  59.  * I/O request struct. Used in DKIOCREQ ioctl to specify one command sequence
  60.  * to be executed.
  61.  */
  62. struct fd_ioreq {
  63.     /* 
  64.      * inputs to driver:
  65.      */
  66.     u_char        density;    /* see FD_DENS_xxx, below */
  67.     int        timeout;    /* I/O timeout in milliseconds. Used
  68.                      * in FDCMD_CMD_XFR commands only. */
  69.     int        command;    /* see FDCMD_xxx, below */
  70.     u_char        cmd_blk[FD_CMDSIZE];
  71.                     /* actual command bytes */
  72.     u_int        num_cmd_bytes;    /* expected # of bytes in cmd_blk[] to
  73.                      * transfer */
  74.     caddr_t        addrs;        /* source/dest of data */
  75.     u_int        byte_count;    /* max # of data bytes to move */
  76.     u_char        stat_blk[FD_STATSIZE];
  77.                     /* status returned from controller */
  78.     u_int        num_stat_bytes;    /* number of status bytes to transfer
  79.                      * to stat_blk[] */
  80.     int         flags;        /* see FD_IOF_xxx, below */
  81.     
  82.     /*
  83.      * outputs from driver:
  84.      */
  85.     fd_return_t    status;        /* FDR_SUCCESS, etc. */
  86.     u_int        cmd_bytes_xfr;    /* # of command bytes actually moved */
  87.     u_int        bytes_xfr;    /* # of data bytes actually moved */
  88.     u_int        stat_bytes_xfr;    /* # if status bytes moved to 
  89.                      * stat_blk[] */
  90.     struct fd_drive_stat drive_stat; /* media ID, etc. */
  91.  
  92.     /*
  93.      * used internally by driver
  94.      */
  95. #ifdef    KERNEL
  96.     pmap_t        pmap;        /* DMA is mapped by this */
  97.     vm_map_t    map;        /* map of requestor's task */
  98. #else    KERNEL
  99.     void        *pmap;
  100.     void        *map;
  101. #endif    KERNEL
  102.     u_char        unit;        /* drive # (relative to controller) */
  103. };
  104.  
  105. typedef struct fd_ioreq fdIoReq_t;    
  106. typedef struct fd_ioreq *fd_ioreq_t;
  107.  
  108. /*
  109.  * fd_ioreq.command values 
  110.  */
  111. #define FDCMD_BAD        0x00    /* not used */
  112. #define FDCMD_CMD_XFR        0x01    /* transfer command in fd_ioreq.cmd_blk
  113.                      */
  114. #define FDCMD_EJECT        0x02    /* eject disk */
  115. #define FDCMD_MOTOR_ON        0x03    /* motor on */
  116. #define FDCMD_MOTOR_OFF        0x04    /* motor off */
  117. #define FDCMD_GET_STATUS    0x05    /* Get status (media ID, motor state,
  118.                      * write protect) */
  119.  
  120. /*
  121.  * fd_ioreq.density values. Some routines rely on these being in
  122.  * cardinal order...
  123.  */
  124. #define FD_DENS_NONE    0        /* unformatted */
  125. #define FD_DENS_1    1        /* 1 MByte/disk unformatted */
  126. #define FD_DENS_2    2        /* 2 MByte/disk unformatted */
  127. #define FD_DENS_4    3        /* 4 MByte/disk unformatted */
  128.  
  129. #if     i386
  130. #define FD_DENS_DEFAULT    FD_DENS_2
  131. #else
  132. #define FD_DENS_DEFAULT FD_DENS_4
  133. #endif
  134.  
  135. /*
  136.  * fd_ioreq.flags values
  137.  */
  138. #define FD_IOF_DMA_DIR        0x00000002
  139. #define FD_IOF_DMA_RD        0x00000002    /* DMA direction = device to
  140.                          * host */
  141. #define FD_IOF_DMA_WR        0x00000000    /* DMA direction = host to
  142.                          * device */
  143.                          
  144. /*
  145.  * fdr_return_t values
  146.  */
  147. #define FDR_SUCCESS        0    /* OK */
  148. #define FDR_TIMEOUT        1    /* fd_ioreq.timeout exceeded */
  149. #define FDR_MEMALLOC        2    /* couldn't allocate memory */
  150. #define FDR_MEMFAIL        3    /* memory transfer error */
  151. #define FDR_REJECT        4    /* bad field in fd_ioreq */
  152. #define FDR_BADDRV        5    /* drive not present */
  153. #define FDR_DATACRC        6    /* media error - data CRC */
  154. #define FDR_HDRCRC        7    /* media error - header CRC */
  155. #define FDR_MEDIA        8    /* misc. media error */
  156. #define FDR_SEEK         9    /* seek error */
  157. #define FDR_BADPHASE        10    /* controller changed phase 
  158.                      * unexpectedly */
  159. #define FDR_DRIVE_FAIL        11    /* Basic Drive Failure */
  160. #define FDR_NOHDR        12    /* Header Not Found */
  161. #define FDR_WRTPROT        13    /* Disk Write Protected */
  162. #define FDR_NO_ADDRS_MK        14    /* Missing Address Mark */
  163. #define FDR_CNTRL_MK        15    /* Missing Control Mark */
  164. #define FDR_NO_DATA_MK        16    /* Missing Data Mark */
  165. #define FDR_CNTRL_REJECT    17    /* controller rejected command */
  166. #define FDR_CNTRLR        18    /* Controller Handshake Error */
  167. #define FDR_DMAOURUN        19    /* DMA Over/underrun */
  168. #define FDR_VOLUNAVAIL        20    /* Requested Volume not available */
  169. #define FDR_ALIGN        21    /* DMA alignment error */
  170. #define FDR_DMA            22    /* DMA error */
  171. #define FDR_SPURIOUS        23    /* spurious interrupt */
  172.  
  173. /*
  174.  * fd_drive_stat.media_id values
  175.  */
  176. #define FD_MID_NONE        0    /* no disk inserted */
  177. #define FD_MID_1MB        3    /* 1 MByte unformatted */
  178. #define FD_MID_2MB        2    /* 2 MByte unformatted */
  179. #define FD_MID_4MB        1    /* 4 MBytes unformatted */
  180.  
  181. #if i386 || hppa
  182. #define FD_MID_DEFAULT    FD_MID_2MB
  183. #ifdef KERNEL                   /* Maximum Number of bytes of data
  184.                           that can be transfered via DMA 
  185.                            using FDIOCREQ ioctl command
  186.                        */
  187.  
  188. #define FD_MAX_DMA_SIZE        PAGE_SIZE 
  189. #else
  190. #define FD_MAX_DMA_SIZE        vm_page_size 
  191. #endif KERNEL                   
  192. #endif i386 || hppa
  193.  
  194. /*
  195.  * ioctl's specific to floppy disk
  196.  */
  197. #define    FDIOCREQ    _IOWR('f', 0, struct fd_ioreq)    /* cmd request */
  198. #define FDIOCGFORM    _IOR ('f', 1, struct fd_format_info)
  199.                             /* get format */
  200. #define FDIOCSDENS    _IOW ('f', 2, int)        /* set density */
  201. #define FDIOCSSIZE    _IOW ('f', 3, int)        /* set sector size */
  202. #define FDIOCSGAPL    _IOW ('f', 4, int)        /* set Gap 3 length */
  203. #define FDIOCRRW    _IOWR('f', 5, struct fd_rawio)    /* raw read/write */
  204. #define FDIOCSIRETRY    _IOW ('f', 6, int)        /* set inner retry loop
  205.                              * count */
  206. #define FDIOCGIRETRY    _IOR ('f', 7, int)        /* get inner retry loop
  207.                              * count */
  208. #define FDIOCSORETRY    _IOW ('f', 8, int)        /* set outer retry loop
  209.                              * count */
  210. #define FDIOCGORETRY    _IOR ('f', 9, int)        /* get outer retry loop
  211.                              * count */
  212. #define    FDIOCGCAPLIST    _IOR ('f', 10, struct fd_cap_list)
  213.                 /* get list of possible    format capacities */
  214. /*
  215.  *     software registers passed to controller during command sequences 
  216.  */
  217.  
  218. struct fd_rw_cmd {
  219.     /*
  220.      * 9 command bytes passed at start of read/write data
  221.      */
  222.      
  223. #if     __LITTLE_ENDIAN__
  224.  
  225.     u_char  opcode:5,
  226.         sk:1,            /* skip sectors with deleted AM */
  227.         mfm:1,            /* MFM encoding */
  228.         mt:1;             /* multi track */
  229.     u_char    drive_sel:2,        /* drive select */
  230.         hds:1,            /* head select */
  231.          rsvd1:5;        /* reserved */
  232.     u_char    cylinder;
  233.     u_char    head;
  234.     u_char    sector;
  235.     u_char    sector_size;        /* 'n' in the Intel spec. */
  236.     u_char    eot;            /* sector # at end of track */
  237.     u_char    gap_length;        /* gap length */
  238.     u_char    dtl;            /* special sector size */
  239.  
  240. #elif    __BIG_ENDIAN__
  241.  
  242.     u_char     mt:1,            /* multitrack */
  243.         mfm:1,            /* MFM encoding */
  244.         sk:1,            /* skip sectors with deleted AM */
  245.         opcode:5;
  246.     u_char    rsvd1:5,        /* reserved */
  247.         hds:1,            /* head select */
  248.         drive_sel:2;        /* drive select */
  249.     u_char    cylinder;
  250.     u_char    head;
  251.     u_char    sector;
  252.     u_char    sector_size;        /* 'n' in the Intel spec. */
  253.     u_char    eot;            /* sector # at end of track */
  254.     u_char    gap_length;        /* gap length */
  255.     u_char    dtl;            /* special sector size */
  256.     
  257. #else
  258. #error    Floppy command / data structures are compiler sensitive
  259. #endif
  260. };
  261.  
  262. #define SIZEOF_RW_CMD    9        /* compiler yields 9 as sizeof this
  263.                      * struct */
  264.                      
  265. struct fd_rw_stat {
  266.     /* 
  267.      * 7 status bytes passed at completion of read/write data 
  268.      */
  269.  
  270.     u_char    stat0;
  271.     u_char    stat1;
  272.     u_char     stat2;
  273.     u_char    cylinder;
  274.     u_char    head;
  275.     u_char    sector;
  276.     u_char    sector_size;        /* 'n' in the Intel spec. */
  277. };
  278.  
  279. #define SIZEOF_RW_STAT    7
  280.  
  281. struct fd_int_stat {
  282.     /* 
  283.      * result of Sense Interrupt Status command
  284.      */
  285.     u_char     stat0;    
  286.     u_char    pcn;            /* present cylinder & */
  287. };
  288.  
  289. struct fd_seek_cmd {
  290.     /* 
  291.      * Seek command. Uses Sense Interrupt Status to get results.
  292.      */
  293.      
  294. #if     __LITTLE_ENDIAN__
  295.  
  296.     u_char    opcode:6,        /* will be FCCMD_SEEK */
  297.         dir:1,            /* 1 == towards spindle for 
  298.                         relative seek*/
  299.         relative:1;        /* 1 = relative */
  300.     u_char    drive_sel:2,        /* drive select */
  301.         hds:1,            /* head select */
  302.         rsvd1:5;        /* reserved */
  303.     u_char    cyl;            /* cylinder # or offset */
  304.     
  305. #elif    __BIG_ENDIAN__
  306.  
  307.     u_char    relative:1,        /* 1 = relative */
  308.         dir:1,            /* 1 == towards spindle */
  309.         opcode:6;        /* will be FCCMD_SEEK */
  310.     u_char    rsvd1:5,        /* reserved */
  311.         hds:1,            /* head select */
  312.         drive_sel:2;        /* drive select */
  313.     u_char    cyl;            /* cylinder # or offset */
  314.     
  315. #else
  316. #error    Floppy command / data structures are compiler sensitive
  317. #endif
  318. };
  319.  
  320. #define SEEK_DIR_IN        1        /* seek towards spindle */
  321. #define SEEK_DIR_OUT        0        /* seek away from spindle */
  322.  
  323. #define SIZEOF_SEEK_CMD        3
  324.  
  325. struct fd_recal_cmd {
  326.     /* 
  327.      * Recalibrate command. Uses Sense Interrupt Status to get results.
  328.      */
  329.     u_char    opcode;            /* will be FCCMD_RECAL */
  330.     
  331. #if     __LITTLE_ENDIAN__
  332.  
  333.     u_char    drive_sel:2,        /* drive select */
  334.         rsvd1:6;        /* reserved */
  335.     
  336. #elif    __BIG_ENDIAN__
  337.  
  338.     u_char    rsvd1:6,        /* reserved */
  339.         drive_sel:2;        /* drive select */
  340.     
  341. #else
  342. #error    Floppy command / data structures are compiler sensitive
  343. #endif
  344. };
  345.     
  346. struct fd_configure_cmd {
  347.     /*
  348.      * configure command. No result bytes are returned.
  349.      */
  350.     u_char     opcode;            /* will be FCCMD_CONFIGURE */
  351.     u_char    rsvd1;            /* must be 0 */
  352.     u_char     conf_2;            /* EIS, EFIFO, etc. */
  353.     u_char    pretrk;            /* write precomp track # */
  354. };
  355.  
  356. /*
  357.  * configure command fields 
  358.  */
  359. #define CF2_EIS            0x40    /* enable implied seek */
  360. #define CF2_EFIFO        0x20    /* enable FIFO. True Low. */
  361. #define CF2_DPOLL        0x10    /* disable polling */
  362. #define CF2_FIFO_DEFAULT    0x08    /* OUR default FIFO threshold */
  363. #define CF_PRETRACK        0x00    /* OUR default precom track */
  364. #define I82077_FIFO_SIZE    0x10    /* size of FIFO */
  365.  
  366. struct fd_specify_cmd {
  367.     /*
  368.      * Specify command. No result bytes are returned.
  369.      */
  370.     u_char     opcode;            /* will be FCCMD_SPECIFY */
  371.     
  372. #if     __LITTLE_ENDIAN__
  373.  
  374.     u_char     hut:4,            /* head unload time */
  375.         srt:4;            /* step rate */
  376.     u_char    nd:1,            /* Non-DMA mode */
  377.         hlt:7;            /* head load time */
  378.     
  379. #elif    __BIG_ENDIAN__
  380.  
  381.     u_char    srt:4,            /* step rate */
  382.          hut:4;            /* head unload time */
  383.     u_char    hlt:7,            /* head load time */
  384.         nd:1;            /* Non-DMA mode */
  385.     
  386. #else
  387. #error    Floppy command / data structures are compiler sensitive
  388. #endif
  389. };
  390.  
  391. #define SIZEOF_SPECIFY_CMD    3
  392.  
  393. struct fd_readid_cmd {
  394.     /* 
  395.      * Read ID command. Returns status in an fd_rw_stat.
  396.      */
  397.      
  398. #if     __LITTLE_ENDIAN__
  399.  
  400.     u_char    opcode:6,        /* Will be FCCMD_READID */
  401.         mfm:1,
  402.          rsvd1:1;
  403.     u_char    drive_sel:2,        /* drive select */
  404.         hds:1,            /* head select */
  405.         rsvd2:5;        /* reserved */
  406.     
  407. #elif    __BIG_ENDIAN__
  408.  
  409.     u_char     rsvd1:1,
  410.         mfm:1,
  411.         opcode:6;        /* Will be FCCMD_READID */
  412.     u_char    rsvd2:5,        /* reserved */
  413.         hds:1,            /* head select */
  414.         drive_sel:2;        /* drive select */
  415.     
  416. #else
  417. #error    Floppy command / data structures are compiler sensitive
  418. #endif
  419. };
  420.  
  421. struct fd_perpendicular_cmd {
  422.     u_char    opcode;            /* will be FCCMD_PERPENDICULAR */
  423.     
  424. #if     __LITTLE_ENDIAN__
  425.  
  426.     u_char    gap:1,
  427.         wgate:1,
  428.         rsvd1:6;        /* must be 0 */
  429.     
  430. #elif    __BIG_ENDIAN__
  431.  
  432.     u_char    rsvd1:6,        /* must be 0 */
  433.         wgate:1,
  434.         gap:1;
  435.     
  436. #else
  437. #error    Floppy command / data structures are compiler sensitive
  438. #endif
  439. };
  440.  
  441. struct fd_format_cmd {
  442.     /*
  443.      * Format track command. Returns status in an fd_rw_stat
  444.      * (with undefined address fields).
  445.      */
  446.      
  447. #if     __LITTLE_ENDIAN__
  448.  
  449.     u_char    opcode:6,        /* will be FCCMD_FORMAT */
  450.         mfm:1,
  451.         rsvd1:1;
  452.     u_char    drive_sel:2,        /* drive select */
  453.         hds:1,            /* head select */
  454.         rsvd2:5;        /* reserved */
  455.     
  456. #elif    __BIG_ENDIAN__
  457.  
  458.     u_char    rsvd1:1,
  459.         mfm:1,
  460.         opcode:6;        /* will be FCCMD_FORMAT */
  461.     u_char    rsvd2:5,        /* reserved */
  462.         hds:1,            /* head select */
  463.         drive_sel:2;        /* drive select */
  464.     
  465. #else
  466. #error    Floppy command / data structures are compiler sensitive
  467. #endif
  468.     u_char    n;            /* sector size (2**n * 128 = sect_size)
  469.                      */
  470.     u_char    sects_per_trk;
  471.     u_char    gap_length;
  472.     u_char    filler_data;        /* data field written with this byte */
  473. };
  474.  
  475. struct fd_sense_drive_status_cmd {
  476.     /*
  477.      * returns one result byte which is basically status register 3
  478.      */
  479.  
  480.     u_char    opcode;     /* will be FCCMD_DRIVE_STATUS */
  481.     
  482. #if     __LITTLE_ENDIAN__
  483.  
  484.     u_char    drive_sel:2,    /* drive select */
  485.         hds:1,        /* head select */
  486.          resvd2:5;     /* always zero */
  487.     
  488. #elif    __BIG_ENDIAN__
  489.  
  490.     u_char    resvd2:5,     /* always zero */
  491.         hds:1,        /* head select */
  492.          drive_sel:2;    /* drive select */
  493.     
  494. #else
  495. #error    Floppy command / data structures are compiler sensitive
  496. #endif
  497. };
  498.  
  499. /*
  500.  *    software register values
  501.  */
  502.  
  503. /*
  504.  * cmd (command byte). Not all of these opcodes are used with the fd_rw_cmd 
  505.  * struct...
  506.  */
  507. #define FCCMD_OPCODE_MASK    0x1F
  508. #define    FCCMD_MULTITRACK    0x80
  509. #define FCCMD_MFM        0x40        /* MFM flag */
  510. #define FCCMD_SK        0x20        /* skip flag */
  511. #define FCCMD_READ        0x06
  512. #define FCCMD_READ_DELETE    0x0C
  513. #define FCCMD_WRITE        0x05
  514. #define FCCMD_WRITE_DELETE    0x09
  515. #define FCCMD_READ_TRACK    0x02
  516. #define FCCMD_VERIFY        0x16
  517. #define FCCMD_VERSION        0x10
  518. #define FCCMD_FORMAT        0x0D
  519. #define FCCMD_RECAL        0x07
  520. #define FCCMD_INTSTAT        0x08        /* sense interrupt status */
  521. #define FCCMD_SPECIFY        0x03
  522. #define FCCMD_DRIVE_STATUS    0x04
  523. #define FCCMD_SEEK        0x0F
  524. #define FCCMD_CONFIGURE        0x13
  525. #define FCCMD_DUMPREG        0x0E
  526. #define FCCMD_READID        0x0A        /* Read ID */
  527. #define FCCMD_PERPENDICULAR    0x12        /* perpendicular recording mode
  528.                          */
  529. /* 
  530.  * rws_stat0 (status register 0)
  531.  */
  532. #define SR0_INTCODE        0xC0    /* interrupt code - see INTCODE_xxx */
  533. #define INTCODE_COMPLETE    0x00    /* normal I/O complete */
  534. #define INTCODE_ABNORMAL    0x40    /* abnormal termination */
  535. #define INTCODE_INVALID        0x80    /* Invalid command */
  536. #define INTCODE_POLL_TERM    0xC0    /* abnormal termination caused by 
  537.                      * polling */
  538. #define SR0_SEEKEND        0x20    /* Seek End */
  539. #define SR0_EQ_CHECK        0x10    /* Equipment check (recal failed,
  540.                      *    seek beyond track 0, etc.) */
  541. #define SR0_HEAD        0x04    /* current head address */
  542. #define SR0_DRVSEL        0x03
  543. #define SR0_DRVSEL1        0x02    /* Drive Select 1 */
  544. #define SR0_DRVSEL0        0x01    /* Drive Select 0 */
  545.  
  546. /*
  547.  * rws_stat1 (status register 1)
  548.  */
  549. #define SR1_EOCYL        0x80    /* end of cylinder */
  550. #define SR1_CRCERR        0x20    /* data or ID CRC error */
  551. #define SR1_OURUN        0x10    /* DMA over/underrun */
  552. #define SR1_NOHDR        0x04    /* Header Not Found */
  553. #define SR1_NOT_WRT        0x02    /* Not writable */
  554. #define SR1_MISS_AM        0x01    /* Missing Address mark */
  555.  
  556. /*
  557.  * rws_stat2 (status register 2)
  558.  */
  559. #define SR2_CNTRL_MK        0x40    /* control mark */
  560. #define SR2_DATACRC        0x20    /* Data CRC error */
  561. #define SR2_WRONG_CYL        0x10    /* wrong cylinder */
  562. #define SR2_BAD_CYL        0x02    /* Bad cylinder */
  563. #define SR2_MISS_AM        0x01    /* missing data mark */
  564.  
  565. /*
  566.  * rws_stat3 (status register 3)
  567.  */
  568. #define SR3_WP            0x40    /* write protected */
  569. #define SR3_TRACK0        0x10    /* Track 0 */
  570. #define SR3_HEAD        0x04    /* Head # */
  571. #define SR3_DRVSEL1        0x02    /* same as status register 0?? */
  572. #define SR3_DEVSEL0        0x01    
  573.  
  574. /*
  575.  * disk info - maps media_id to tracks_per_cyl and num_cylinders.
  576.  */
  577. struct fd_disk_info {
  578.     u_int     media_id;            /* FD_MID_1MB, etc. */
  579.     u_char    tracks_per_cyl;            /* # of heads */
  580.     u_int    num_cylinders;    
  581.     u_int    max_density;            /* maximum legal density.
  582.                          * (FD_DENS_1, etc.) */
  583. };
  584.  
  585. /*
  586.  * sector size info - maps sector size to 82077 sector size code and
  587.  * gap3 length.  Note that the controller must be programmed for different
  588.  * gap3 size when formatting as opposed to reading or writing.  Since gap3
  589.  * sizes may be dependent on the actual disk hardware, the fmt gap is
  590.  * maintained here to avoid requiring the formatter to determine
  591.  * the disk device type.
  592.  */
  593. struct fd_sectsize_info {
  594.     u_int         sect_size;        /* in bytes */
  595.     u_char        n;            /* 82077 sectsize code */
  596.     u_int        sects_per_trk;        /* physical sectors per trk */
  597.     u_char        rw_gap_length;        /* Gap 3 for rw cmds */ 
  598.     u_char        fmt_gap_length;        /* Gap 3 for fmt cmds */ 
  599. };
  600.  
  601. typedef struct fd_sectsize_info fd_sectsize_info_t;
  602.  
  603. /*
  604.  * density info - maps density to capacity. Note that a disk may be formatted
  605.  * with a lower density than its max possible density.
  606.  */
  607. struct fd_density_info {
  608.     u_int         density;        /* FD_DENS_1, etc. */
  609.     u_int         capacity;        /* in bytes */
  610.     boolean_t    mfm;            /* TRUE = MFM encoding */
  611. };
  612.  
  613. typedef struct fd_density_info fd_density_info_t;
  614.  
  615. /*
  616.  * disk format info. Used with ioctl(FDIOCGFORM).
  617.  */
  618. struct fd_format_info {
  619.     /*
  620.      * the disk_info struct is always valid as long as a disk is
  621.      * inserted.
  622.      */
  623.     struct fd_disk_info    disk_info;
  624.     
  625.     int            flags;        /* See FFI_xxx, below */
  626.  
  627.     /*
  628.      * the remainder is only valid if (flags & FFI_FORMATTED) is true.
  629.      */
  630.     struct fd_density_info    density_info;
  631.     struct fd_sectsize_info    sectsize_info;
  632.     u_int            total_sects;    /* total # of sectors on 
  633.                          * disk */
  634. };
  635.  
  636. /*
  637.  * fd_format_info.flags fields
  638.  */
  639. #define FFI_FORMATTED        0x00000001    /* known disk format */
  640. #define FFI_LABELVALID        0x00000002    /* Valid NeXT file system label
  641.                          * present */
  642. #define FFI_WRITEPROTECT    0x00000004    /* disk is write protected */
  643.                          
  644. struct format_data {
  645.     /* 
  646.      * one of these per sector. A Format command involves DMA'ing one of 
  647.      * these for each sector on a track. The format command is executed
  648.      * with a FDIOCREQ ioctl.
  649.      */
  650.     u_char cylinder;
  651.     u_char head;
  652.     u_char sector;
  653.     u_char n;            /* as in sector_size = 2**n * 128 */
  654. };
  655.  
  656. /*
  657.  * result of FCCMD_DUMPREG command
  658.  */
  659. struct fd_82077_regs {
  660.     u_char    pcn[4];        /* cylinder # for drives 0..3 */
  661.     u_char    srt:4,
  662.         hut:4;
  663.     u_char    hlt:7,
  664.         nd:1;
  665.     u_char    sc_eot;
  666.     u_char    rsvd1;
  667.     u_char    rsvd2:1,
  668.         eis:1,
  669.         efifo:1,
  670.         poll:1,
  671.         fifothr:4;
  672.     u_char    pretrk;
  673. };
  674.  
  675. /*
  676.  * Used for FDIOCRRW - raw disk I/O 
  677.  * -- no bad block mapping
  678.  * -- no label required
  679.  * -- no front porch 
  680.  * -- block size = physical sector size
  681.  */
  682. struct fd_rawio {
  683.     /*
  684.      * Passed to driver
  685.      */
  686.     u_int         sector;
  687.     u_int        sector_count;
  688.     caddr_t        dma_addrs;
  689.     boolean_t    read;        /* TRUE = read; FALSE = write */
  690.     /*
  691.      * Returned from driver
  692.      */
  693.     fd_return_t    status;        /* FDR_xxx (see above) */
  694.     u_int         sects_xfr;    /* sectors actually moved */
  695. };
  696.  
  697. /*
  698.  * misc. hardware constants
  699.  */
  700. #define NUM_FD_HEADS     2        /* number of tracks/cylinder */
  701. #define NUM_FD_CYL    80        /* cylinders/disk (is this actually a 
  702.                      * constant for all densities?) */
  703. #define FD_PARK_TRACK    79        /* track to which to seek before
  704.                      * eject */
  705. #define NUM_UNITS    4        /* max # of drives per controller */ 
  706.  
  707. #endif    _FDEXTERN_
  708.